package com.sunshine.simplehospital.adapter

import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.youth.banner.adapter.BannerAdapter

/**
 * Created by sunshine on 2020/4/29
 */
class MainBannerAdapter(list: List<Int>) : BannerAdapter<Int, MainBannerAdapter.MainBannerViewHolder>(list) {

    inner class MainBannerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
        val imageView: ImageView = itemView as ImageView
    }

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): MainBannerViewHolder {
        val imageView = ImageView(parent?.context)
        imageView.layoutParams = ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT
        )
        return MainBannerViewHolder(imageView)
    }

    override fun onBindView(holder: MainBannerViewHolder?, data: Int?, position: Int, size: Int) {
        holder!!.imageView.setImageResource(data!!)
    }

}